<?php



/**
 * Radcodes - SocialEngine Module
 *
 * @category   Application_Extensions
 * @package    Gmap
 * @copyright  Copyright (c) 2009-2010 Radcodes LLC (http://www.radcodes.com)
 * @license    http://www.radcodes.com/license/
 * @version    $Id$
 * @author     Vincent Van <vincent@radcodes.com>
 */
 
 
 
class Gmap_Form_Admin_Global extends Engine_Form
{
  public function init()
  {
    $this
      ->setTitle('Global Settings')
      ->setDescription('These settings affect all members in your community.');
    
    $this->addElement('Text', 'gmap_license', array(
      'label' => 'Gmap License Key',
      'description' => 'GMAP_FORM_ADMIN_GLOBAL_GMAPLICENSE_DESCRIPTION',
      'value' => Engine_Api::_()->getApi('settings', 'core')->getSetting('gmap.license', 'XXXX-XXXX-XXXX-XXXX'),
      'filters' => array(
        'StringTrim'
      ),
      'allowEmpty' => false,
      'validators' => array(
        new Radcodes_Lib_Validate_License('gmap'),
      ),
    ));
      
      
    $this->addElement('Radio', 'gmap_public', array(
      'label' => 'Public Permissions',
      'description' => "GMAP_FORM_ADMIN_GLOBAL_GMAPPUBLIC_DESCRIPTION",
      'multiOptions' => array(
        1 => 'Yes, the public can view gmaps unless they are made private.',
        0 => 'No, the public cannot view gmaps.'
      ),
      'value' => Engine_Api::_()->getApi('settings', 'core')->getSetting('gmap.public', 1),
    ));
      
    $this->addElement('Radio', 'gmap_sorting', array(
      'label' => 'Sorting Priority',
      'description' => "GMAP_FORM_ADMIN_GLOBAL_GMAP_SORTING_DESCRIPTION",
      'multiOptions' => array(
				0 => "User preference",
        1 => "Sponsored gmaps, then user preference",
        2 => "Sponsored gmaps, featured gmaps, then user preference",
				3 => "Featured gmaps, then user preference",
				4 => "Featured gmaps, sponsored gmaps, then user preference",
      ),
      'value' => Engine_Api::_()->getApi('settings', 'core')->getSetting('gmap.sorting', 1),
    ));
      
    $this->addElement('Text', 'gmap_page', array(
      'label' => 'Gmaps Per Page',
      'description' => 'GMAP_FORM_ADMIN_GLOBAL_GMAP_PAGE_DESCRIPTION',
      'class' => 'short',
      'value' => Engine_Api::_()->getApi('settings', 'core')->getSetting('gmap.page', 20),
      'validators' => array(
        'Digits',
        new Zend_Validate_Between(1,100),
      ),
    ));


    $this->addElement('Text', 'gmap_gallery', array(
      'label' => 'Gmap Photos',
      'description' => 'GMAP_FORM_ADMIN_GLOBAL_GMAP_GALLERY_DESCRIPTION',
      'class' => 'short',
      'value' => Engine_Api::_()->getApi('settings', 'core')->getSetting('gmap.gallery', 3),
    ));

    
    $this->addElement('Radio', 'gmap_distanceunit', array(
      'label' => 'Distance Unit',
      'description' => "GMAP_FORM_ADMIN_GLOBAL_GMAP_DISTANCE_UNIT",
      'multiOptions' => array(
        Radcodes_Lib_Helper_Unit::UNIT_MILE => "Mile (ml)",
        Radcodes_Lib_Helper_Unit::UNIT_KILOMETER => "Kilometer (km)",
      ),
      'value' => Engine_Api::_()->getApi('settings', 'core')->getSetting('gmap.distanceunit', Radcodes_Lib_Helper_Unit::UNIT_MILE),
    ));
    
    $this->addElement('Radio', 'gmap_standardizeaddress', array(
      'label' => 'Standardize Address',
      'description' => "GMAP_FORM_ADMIN_GLOBAL_GMAP_STANDARDIZE_ADDRESS",
      'multiOptions' => array(
        1 => 'Yes, display the formatted address of user input location address.',
        0 => 'No, display user input location address as it is.'
      ),
      'value' => Engine_Api::_()->getApi('settings', 'core')->getSetting('gmap.standardizeaddress', 0),
    ));
    
    /*
    $this->addElement('Text', 'gmap_homerecentmax', array(
      'label' => 'Recently Posted Gmaps',
      'description' => 'How many gmaps will be shown in the Recently Posted section? (Enter a number between 1 and 20)',
      'class' => 'short',
      'value' => Engine_Api::_()->getApi('settings', 'core')->getSetting('gmap.homerecentmax', 5),
      'validators' => array(
        'Digits',
        new Zend_Validate_Between(1,20),
      ), 
    ));  
    
    $this->addElement('Text', 'gmap_homefeaturedmax', array(
      'label' => 'Featured Gmaps',
      'description' => 'How many gmaps will be shown in the Featured section? (Enter a number between 0 and 10)',
      'class' => 'short',
      'value' => Engine_Api::_()->getApi('settings', 'core')->getSetting('gmap.homefeaturedmax', 3),
      'validators' => array(
        'Digits',
        new Zend_Validate_Between(0,10),
      ),    
    ));    
    
    $this->addElement('Text', 'gmap_homesponsoredmax', array(
      'label' => 'Sponsored Gmaps',
      'description' => 'How many gmaps will be shown in the Sponsored section? (Enter a number between 0 and 10)',
      'class' => 'short',
      'value' => Engine_Api::_()->getApi('settings', 'core')->getSetting('gmap.homesponsoredmax', 3),
      'validators' => array(
        'Digits',
        new Zend_Validate_Between(0,10),
      ), 
    ));      

    
    $this->addElement('Text', 'gmap_homecommentedmax', array(
      'label' => 'Most Commented Gmaps',
      'description' => 'How many gmaps will be shown in the Most Commented section? (Enter a number between 0 and 10)',
      'class' => 'short',
      'value' => Engine_Api::_()->getApi('settings', 'core')->getSetting('gmap.homecommentedmax', 5),
      'validators' => array(
        'Digits',
        new Zend_Validate_Between(0,10),
      ), 
    ));     
    
    $this->addElement('Select', 'gmap_homecommentedperiod', array(
    //  'label' => 'Landing - Most Commented Period',
      'description' => 'What publishing period should be used for Most Commented section?',
      'multiOptions' => array(
        0 => "All Time",
        7 => "This Week",
        30 => "This Month",
        90 => "3 Months",
        180 => "6 Months",
        365 => "This Year",
      ),
      'value' => Engine_Api::_()->getApi('settings', 'core')->getSetting('gmap.homecommentedperiod', 30),
    ));     
    
    $this->addElement('Text', 'gmap_homeviewedmax', array(
      'label' => 'Most Viewed Gmaps',
      'description' => 'How many gmaps will be shown in the Most Viewed section? (Enter a number between 0 and 10)',
      'class' => 'short',
      'value' => Engine_Api::_()->getApi('settings', 'core')->getSetting('gmap.homeviewedmax', 5),
      'validators' => array(
        'Digits',
        new Zend_Validate_Between(0,10),
      ),     
    ));       

    $this->addElement('Select', 'gmap_homeviewedperiod', array(
     // 'label' => 'Landing - Most Viewed Period',
      'description' => 'What publishing period should be used for Most Viewed section?',
      'multiOptions' => array(
        0 => "All Time",
        7 => "This Week",
        30 => "This Month",
        90 => "3 Months",
        180 => "6 Months",
        365 => "This Year",
      ),
      'value' => Engine_Api::_()->getApi('settings', 'core')->getSetting('gmap.homeviewedperiod', 30),
    ));     
    */    
    
    // Add submit button
    $this->addElement('Button', 'submit', array(
      'label' => 'Save Changes',
      'type' => 'submit',
      'ignore' => true
    ));
  }
}